<?php $this->load->view('qt/header'); ?>


<!--  PAPER WRAP -->
<div class="wrap-fluid">
    <div class="container-fluid paper-wrap bevel tlbr">

        <!-- CONTENT -->
        <!--TITLE -->
        <div class="row">
            <div id="paper-top">
                <div class="col-sm-12">
                    <h2 class="tittle-content-header">
                        <i class="qt-network"></i>
                        <span id="title-header">
                            <?php echo (isset($this->title_header)) ? $this->title_header : 'TRANG CHÍNH';?>
                        </span>
                    </h2>
                </div>
            </div>
        </div>
        <!--/ TITLE -->
        <ul id="breadcrumb">
            <li><span class="entypo-home"></span></li>
            <li><i class="fa fa-lg fa-angle-right"></i></li>
            <li><a href="#main">Trang chủ</a></li>
        </ul>
        <div class="content-wrap"  style="margin-top: 10px; height: 900px;">
<?php
$n=0;
$array=array('comp_tax_code','comp_name','comp_address','comp_phone','comp_bank_account','comp_img_verify','comp_img_tax');
foreach($array as $v){
	if($this->data["result"][$v]!=""){
		$n+=1;
	}
}
$color="danger";
$px=round($n/(count($array))*100);
?>
<section class="vbox" id="detail_companies">
	<section class="scrollable">
		<section class="hbox stretch">
			<aside class="col-lg-4 bg-light lter b-r" style="padding-right: 0px !important;">
				<section class="vbox">
					<section class="scrollable">
						<div class="wrapper">
							<section class="panel no-border bg-bla lt">
								<div class="panel-body" style="padding: 0px !important;">
									<div class="row m-t-xl" style="padding: 0px !important; margin: 0px !important;">
										<div class="col-xs-12 text-center" style="padding: 0px !important;">
                                            <header class="qth" style="font-size: 12px; 
                                                            font-weight: bold;
                                                            border: 1px solid #bcbcbc;
                                                            width: 100%;
                                                            height: 35px;
                                                            padding-top: 6px;">Thông tin doanh nghiệp</header>
											<div class="qtbr"><!-- inline -->
												<div  style="width: 140px; height: 140px; line-height: 140px;margin: 0 auto;">
													<div class="thumb-lg avatar">
														<img src="<?php echo base_url();?>/images/avatar.png" class="dker">
													</div>
													<canvas width="140" height="140" style="display: none;"></canvas>
													<input type="hidden" id="comp_id" value="<?php echo $_REQUEST["id"]?>">
													<!--<input type="hidden" value="<?php echo $_REQUEST["id"]?>" id="cust_id"/>-->
												</div>
                                                <p>
													    <div  style="padding-right: 5px;border: none;font-size: 16px;" class="text-lt font-bold pointer editable editable-click" id="dt_comp_name" data="comp_name">
													   <?php echo $this->data["result"]["comp_name"];?>
													   </div>
                                                       &nbsp;
                                                       <?php //echo $this->data["result"]["cust_last_name"];?>
                                                       </p>
                                                <p style="color: #ff6700;">
                                                <?php echo ucfirst($this->data["result"]["comp_address"]);?></p>
											
                                            <div class="row m-t-lg">
											<div class="col-xs-6 col-xs-offset-3 text-center">
												<small style="color: #ff6700;">Tình trạng</small>
												<div class="text-lt font-bold">
													<?php 
													$is_account = false;
														$per = $this->session->userdata('user_info');
														//print_r($per);
														$my_permisstion = $per["permission_apps"]["AM_SALE_SUPPORT"];
														if(isset($my_permisstion["user_type"])&&count($my_permisstion)>0&&$my_permisstion!=""){
															foreach($my_permisstion["user_type"] as $key => $v){
																if(strtoupper($key)=="IS_ACCOUNT"&&$v==1){							
																	$is_account =true;														
																}
															}
														}
														
														if($is_account){
														?>
														<form action="" method="POST" class="form_verify">
															<input type="hidden" name="mod" value="verify">
															<?php 
														//	print_r($this->data["result"]);
															if($this->data["result"]["comp_status"]==-2){
																echo '<button type="button" onclick="viewMsg(\'Khách hàng này đang chờ Sale Quản Lý Xử lý\')" class="btn btn-warning btn-s-lg">Đang bị confLict</button>';
															}else if($this->data["result"]["comp_status"]==0){
																if($px<100){
																	echo '<button type="button" onclick="viewMsg(\'Vui lòng cập nhật đầy đủ thông tin mới được xác nhận.<br/> Thông tin đang đã được cập nhật '.$px.'%\')" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																}else{
																	echo '<button type="button" onclick="validate_verify()" class="btn btn-danger btn-s-lg qtl"><li class="qt-cam" style="font-size: 22px; color: black;list-style: none; float: left;">&nbsp;</li>Chưa xác nhận</button>';
																}

															}else if($this->data["result"]["comp_status"]==1){
																echo '<button type="button" class="btn btn-primary btn-s-lg">Đã Xác Nhận</button>';
															}else{

															}
															?>
														</form>
														<?php }else{
															if($this->data["result"]["comp_status"]==-2){
																echo '<span class="label bg-warning">Đang bị confLict</span>';
															}else if($this->data["result"]["comp_status"]==0){
																
																echo '<span class="label bg-danger btn-s-lg qtl"><li class="qt-cam" style="font-size: 22px; color: black;list-style: none; float: left;">&nbsp;</li> Chưa xác nhận</span>';
																

															}else if($this->data["result"]["comp_status"]==1){
																echo '<span class="label bg-success">Đã Xác Nhận</span>';
															}else{

															}

														}?>
													</div>
												</div>
											</div>
                                            
											</div>
										</div>
									</div>
									<input type="hidden" id="comp_id" value="<?php echo $_REQUEST["id"]?>">
									<div class="wrapper m-t m-b  qtIn">
										<input type="hidden" id="comp_id" value="">
										<div class="row m-b" style="margin: 0px; padding: 0px;">
											<div class="col-xs-12 text-right qta qtto" > 
                                            <div class="col-xs-6">
                                            <small>Đại diện pháp lý</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable editable-click"  id="dt_ceo_name" data="comp_ceo_name">
                                            <?php echo $this->data["result"]["comp_ceo_name"]?>
                                            </div>
											<li class="l-none qt-pencil"></li>
                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Mã số thuế</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable editable-click" style="color: #424242;"  id="dt_tax_code" data="comp_tax_code">
													<?php echo $this->data["result"]["comp_tax_code"]?>
											</div>
											<li class="l-none qt-pencil"></li>
                                            </div>
											</div>
											
											  <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Địa Chỉ</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable editable-click" style="color: #424242;"  id="dt_comp_address" data="comp_address">
													<?php echo $this->data["result"]["comp_address"]?>
											</div>
											<li class="l-none qt-pencil"></li>
                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Số điện thoại</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable editable-click" style="color: #424242;" id="dt_phone" data="comp_phone">
													<?php echo $this->data["result"]["comp_phone"]?>
											</div>
											<li class="l-none qt-pencil"></li>
                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none; min-height: 100px;" > 
                                            <div class="col-xs-6">
                                            <small>Tài khoản ngân hàng</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="content text-lt font-bold pointer editable editable-pre-wrapped editable-click qttera" 
                                            id="dt_bank" data-type="textarea" data="comp_bank_account"
                                            >
													<?php echo $this->data["result"]["comp_bank_account"]?>
											</div>
											<li class="l-none qt-pencil"></li>

                                            </div>
											</div>
										
										</div>
										</div>
										<footer class="panel-footer dk text-center no-border" style="background: #bcbcbc; display: none">
											<div class="row pull-out">
												<div class="col-xs-12">
													<div class="padder-v">
													<small class="text-muted" style="color: white; font-size: 12px; float: left">Người đại diện <?php echo count($this->data["result_cust"]);?></small>
													</div>
												</div>
											</div>
										</footer>
									</div>
									<footer class="panel-footer dk text-center no-border" style="display: none;">
										<div class="row pull-out">
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4 dker">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
										</div>
									</footer>
								</section>
							</div>
						</section>
					</section>
				</aside>
				<aside class="col-lg-8 b-l no-padder" style="padding-left: 0px !important;">
					<section class="vbox">
						<section class="scrollable">
							<div class="wrapper" style="width: 100%;">
								<div class="msg-data"></div>
								<section class="panel panel-warning portlet-item qtbot" >
									<header class="panel-heading qth">Chứng từ số</header>
									<div class="row">
										<div class="col-lg-12">
											<ul class="list-inline" id="img_verify_result" style="padding: 15px 15px 0;">
													<?php
													$imageUpload = json_decode($this->data["result"]["comp_img_verify"],true);
													if(count($imageUpload)>0){
														foreach($imageUpload as $num=> $val){
														$ex = explode(".",strtolower($val));
														$img =$val;
														if(end($ex)=="pdf"){
															$img = base_url("images/icon_pdf.png");
														}
															echo '<li class="im_verify_'.$num.'">
															<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$img.'" style="width:150px;height:120px;"></a>
															<span class="img-remove" onclick="remove_img_verify('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
															</li>';
														}
													}										
													?>
												</ul>
									</div>
								</div>
								<div class="row">
									<div class="col-lg-11 col-lg-offset-1" style="margin-left: 20px !important;">
										<div id="img_comp" >
                                        
                                        </div>
									</div>
								</div>
								<div class="row" style="padding: 10px">
									<div class="col-lg-12">
									<i>	<strong>&nbspLưu ý</strong>:<br/>&nbsp- Chứng từ số bao gồm (giấy phép kinh doanh, giấy ủy quyền người đại diện pháp luật không phải là người đăng ký)</i>
									</div>
								</div>
							</section>

							<section class="panel panel-danger portlet-item" style="border: 1px solid #bcbcbc !important;">
										<header class="panel-heading qth">Hình ảnh Chứng Từ Thuế</header>
										<div class="row">
											<div class="col-lg-12">
												<ul class="list-inline" id="img_tax_result" style="padding: 15px 15px 0;">
													<?php
													$imageUpload = json_decode($this->data["result"]["comp_img_tax"],true);
													if(count($imageUpload)>0){
														foreach($imageUpload as $num=> $val){
														$ex = explode(".",strtolower($val));
														$img =$val;
														if(end($ex)=="pdf"){
															$img = base_url("images/icon_pdf.png");
														}
															echo '<li class="im_tax_'.$num.'">
															<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$img.'" style="width:150px;height:120px;"></a>
															<span class="img-remove" onclick="remove_img_tax('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
															</li>';
														}
													}
													?>
												</ul>
											</div>
										</div>

										<div class="row">
											<div class="col-lg-11 col-lg-offset-1" style="margin-left: 20px !important;">
												<div id="img_tax">
		                                        
		                                        </div>
											</div>
										</div>
									<div class="row" style="padding: 10px">	
											<div class="col-lg-12">
									<i>	<strong>&nbspLưu ý</strong>:<br/>&nbsp- Chứng từ thuế (Form 08) và hình ảnh  thông tin doanh nghiệp <a class="ahover" href="<?php echo base_url()?>images/thong-tin-thue.jpg" class="fancybox">Click để xem mẫu</a><br/>
									&nbsp- Truy cập vào <a class="ahover" href="http://gdt.gov.vn/wps/portal/home/tcnnt" >http://gdt.gov.vn</a> để lấy thông tin</i>
									</div>
									
									</div>
									</section>

							<?php 
							// QUYEN TRUONG PHONG SALE
							$user_info =  $this->session->userdata('user_info');
							//print_r($user_info);
							$is_sale =false;		
							$my_permisstion = $user_info["permission_apps"]["AM_SALE_SUPPORT"];
							if(isset($my_permisstion["user_type"])&&count($my_permisstion)>0&&$my_permisstion!=""){
				
							foreach($my_permisstion["user_type"] as $key => $v){
								if(strtoupper($key)=="IS_SALE"&&$v==1){							
									$is_sale =true;														
								}
							}
						}
						
							
							if($is_sale||isset($my_permisstion["customer"]["index"])){?>	
							<section class="panel-default">
								<header class="panel-heading  qtthead">
                                <li class="qt-user qtthead1">&nbsp;</li>
                                Người đại diện</header>
									<section class="panel panel-default list-sale qts" id="progressbar">
										
										<table class="table table-striped table-condensed table-hover table-bordered">
											<thead>
												<tr>
													<th class="col-md-5">Họ tên</th>
													<th class="col-md-3">Thông tin</th>
													<th class="col-md-2">Tình trạng</th>
													<th class="col-md-2">Tài khoản</th>
												</tr>
											</thead>
											<tbody>
												<?php
												foreach($this->data["result_cust"] as $val){
													$n=0;
													$array=array('cust_first_name','cust_last_name','cust_tax_code','cust_address','cust_phone','cust_email','cust_dob','cust_bank_account','cust_cmnd','cust_cmnd_date','cust_cmnd_images','cust_sex');
													foreach($array as $v){
														if($val[$v]!=""){
															$n+=1;
														}
													}
													$color="danger";
													$px=round($n/(count($array))*100);
													if($px>=100){
														$color="success";
													}else if($px>=50){
														$color="warning";
													}
													?>

													<tr>
														<td><a href="<?php echo base_url()?>customer/detail?id=<?php echo $val["cust_id"]?>"><?php echo $val['cust_first_name'].' '.$val['cust_last_name'];?></a></td>
														<td>
															<div class="progress m-b-none active qt-nl">
															 <div class="progress m-b-none  active">
															 <div class="progress-bar bg-<?php echo $color?>" data-toggle="tooltip" 
															 data-original-title="<?php echo $px?>%" style="width: <?php 
																					 	if($px < 30)
																					 		echo 30;else
																					 echo $px; ?>%">
															 <span class="per-def"><?php echo $px?>%</span></div>
															 														</td>
														<td><a class="qTop" href="<?php echo base_url()?>customer/detail?id=<?php echo $val["cust_id"]?>">
															<?php 
															if(isset($_GET['debug'])){
																echo '<span class="label bg-danger qblack btn-primary" style="color: white">
																	<i data-toggle="tooltip" class="qt-ok"></i>
																	Đã xác nhận</span>';
															}else{
																if($val["cust_status"]==0){
																	echo '<span class="label bg-danger qblack">
																	<i data-toggle="tooltip" class="qt-cam" style="color: black; font-size: 16px;"></i>
																	Chưa xác nhận</span>';
																}else if($val["cust_status"]==-2){
																	echo '<span class="label bg-danger qblack">
																	<i data-toggle="tooltip" class="qt-cam" style="color: black; font-size: 16px;"></i>
																	Đang xử lý</span>';
																}else if($val["cust_status"]==1){
																	echo '<span class="label bg-danger qblack btn-primary" style="color: white">
																	<i data-toggle="tooltip" class="qt-ok"></i>
																	Đã xác nhận</span>';
																}else{
																	echo '<span class="label bg-danger qblack">
																	<i data-toggle="tooltip" class="qt-cam" style="color: black; font-size: 16px;"></i>
																	Chưa xác nhận</span>';
																}
															}

															?>
														</a></td>
														<td class="text-center">
															<?php 
															if($val["cust_username"]!=""){
																echo '<span class="qTop">'.$val["cust_username"].'</span>';
															}else{
																?>
																<button class="btn btn-primary btn-xs btn_create_acc" rel="<?php echo $val['cust_id']?>">Yêu cầu Tạo TK</button>
																<?php
															}
															?>
														</td>
													</tr>
													<?php
												}
												?>
											</tbody>
										</table>
										<footer class="footer bg-white b-t">
										   <div class="row text-center-xs">
										      <div class="col-md-12 col-sm-12 text-center text-center-xs">
										         <ul class="paging-sale pagination pagination-sm m-t-sm m-b-none"></ul>
										      </div>
										   </div>
										</footer>
									</section>	
							</section>						
							<?php }?>
                        
					</section>
				</section>
			</aside>

		</section>
	</section>
</section>

</div>
<div class="content-wrap" id="show-content2"></div>
<div class="content-wrap"> 
<?php $this->load->view('qt/footer'); ?>